import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location){
  return originalPush.call(this, location).catch(err=>err)
}

import Main from '@/views/Main'
import Recommend from '@/views/Recommend'
import Singer from '@/views/Singer'
import Album from '@/views/Album'
import Radio from '@/views/Radio'
import Search from '@/views/Search'
import AlbumDetail from '@/views/AlbumDetail'
import RadioDetail from '@/views/RadioDetail'
import SingerDetail from '@/views/SingerDetail'

const routes = [
  {
    path: '/',
    component: Main,
    children: [
      { path: '', component: Recommend },
      { path: 'recommend', component: Recommend },
      { path: 'singer', component: Singer },
      { path: 'album', component: Album },
      { path: 'radio', component: Radio },
      { path: 'search', component: Search },
      { path: '/albumdetail', component: AlbumDetail },
      { path: '/radiodetail', component: RadioDetail },
      { path: '/singerdetail', component: SingerDetail }
    ]
  },

]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

export default router
